package Shared;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import Simulator.ER;

/**
 * The Telephone module, see Architecture report for specifications.
 */

public class Telephone {

	private static final BlockingQueue<ER> q = new LinkedBlockingQueue<ER>();

	/**
	 * Add an emergency to the call queue.
	 * 
	 * @param e
	 *            the emergency that is notified
	 * @throws InterruptedException
	 */
	public static void call(ER e) throws InterruptedException {
		q.put(e);
	}

	/**
	 * Returns and remove the oldest emergency in queue the call queue.
	 * 
	 * @throws InterruptedException
	 */
	public static ER answer() throws InterruptedException {
		return q.take();
	}

}
